#ifndef FILEMANAGER_H
#define FILEMANAGER_H
#include <QDir>
#include <QDebug>
#include<QVector>
#include "GameData/jsontranslator.h"
//管理文件,读写磁盘（
//singleton
class FileManager
{
public:
    enum FileType{
        IMAGE,
        SOUND,
        VIDEO
    };
    FileManager(const FileManager&) = delete;
    FileManager& operator = (const FileManager&) = delete ;
    static FileManager& Instance();
    ~FileManager();
    void CreateDir(QString path);
    void DeleteDir(QString path);
    //将src下的所有子文件夹和文件拷贝一份到des中
    void CopyDir(QString des,QString src);
    void CopyFile(QString src,QString des,bool justDir);
    //justDir = true则des仅为目录路径。否则还带有文件名
    bool DeleteFile(QString path);
    void MoveFile(QString src,QString des);
    void RenameFile(QString path,QString name);
    static int GetFileType(QString path);
    //Ctrl+D保存
    void SaveData();
    QString curPath = "";

    void SetRootPath(QString path);
    QString GetRootPath();
    //数据持久化
    void Write(QString path,QByteArray content);
    //读取
    QJsonObject* ReadJsonFile(const QString& path);

    //工作目录
    QString rootPath = "D:/test";
    //存储UI编辑器按钮数据
    QString uiEditorBtnsPath = "EditorData/UIEditor/btns.json";
    //存储UI编辑器Label数据
    QString uiEditorLabelsPath = "EditorData/UIEditor/labels.json";
    //存储UI编辑器界面数据
    QString uiEditorInterfacesPath = "EditorData/UIEditor/interfaces.json";
    //存储剧情节点
    QString nodeTreePath = "gameData/nodeTree.json";
    //存储游戏初始数值数据
    QString gameDataPath = "gameData/data.json";
    //存档
    QString recordPath = "gameData/record.json";
    //存储游戏特效数据
    QString effectPath = "EditorData/effect.json";
    //存储图鉴集
    QString albumPath = "gameData/album.json";
    //游戏图标路径
    QString iconPath = "globalData/icon.png";
    //游戏bgm路径
    QString bgmPath = "globalData/bgm.mp3";
    //全局数据路径
    QString gameManagerData = "globalData/gamemanager.json";
private:
    FileManager();
};



#endif // FILEMANAGER_H
